<template>
  <div class="item_list">
    <el-card shadow="hover" :body-style="{ padding: '10px', position: 'relative' }">
      <div class="upload_game_img">
        <img v-if="peopleData.paperImage" class="show_img" :src="getStaticFileUrl(peopleData.paperImage)" alt="">
        <div v-else>
          <p>证书</p>
        </div>
      </div>
      <div class="auth_text">
        <div class="gl_mt_15" style="font-size: 16px;">{{ peopleData.paperDesc }}</div>
        <div v-if="peopleData.paperNumber" style="font-size: 16px;">证书编号：{{ peopleData.paperNumber }}</div>
      </div>
      <el-row type="flex" align="bottom">
        <el-col :span="24" align="right">
          <el-button type="primary" size="mini" @click="edit(peopleData)">编辑</el-button>
          <el-button size="mini" @click="remove(peopleData.id)">删除</el-button>
        </el-col>
      </el-row>
    </el-card>

    <Dialog ref="dialog" :people-data="peopleData" :title="title" :tag-id="tagId" />
  </div>
</template>
<script>
import Dialog from './dialog.vue';
import {
  api_DELETE_EventsManagementRegisterTagRegisterTagDetailRegisterTagDetailId
} from '@/extend/api/gameswaggerApi/app.js';
export default {
  name: 'PeopleList',
  components: {
    Dialog
  },
  props: {
    peopleData: {
      type: Object,
      default() {
        return {
          paperImage: '',
          paperNumber: '',
          paperDesc: ''
        };
      }
    },
    tagId: {
      type: String,
      default: ''
    }
  },
  data () {
    return {
      // editData: {},
      title: '证书编辑'
    };
  },
  methods: {
    // 图片回显
    getStaticFileUrl(relativeUrl) {
      if (!relativeUrl) return '';
      return WEB_CONFIG.VUE_APP_STATIC_FILE_RUL + relativeUrl;
    },
    // 编辑
    edit(peopleData) {
      // this.editData = peopleData;
      this.$refs.dialog.open();
    },
    // 删除
    remove(id) {
      var that = this;
      this.$confirm('您确定要删除此证书？', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        api_DELETE_EventsManagementRegisterTagRegisterTagDetailRegisterTagDetailId(id).then(res => {
          that.$message({
            type: 'success',
            message: '删除成功!'
          });
          that.getRegisterList();
        });
      }).catch(() => {
        this.$message({
          type: 'info',
          message: '取消删除'
        });
      });
    },
    // 更新视图
    getRegisterList() {
      this.$parent.$parent.$parent.getRegisterList();
    }
  }
};
</script>
<style scoped>
.auth_box {
  width: 340px;
  height: 320px;
  border: 1px solid #31456c;
  border-radius: 5px;
  padding: 22px 24px;
}
.upload_game_img {
  display: flex;
  width: 267px;
  height: 178px;
  font-size: 20px;
  text-align: center;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.02);
  border: 1px dashed rgba(0,0, 0, 0.15);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 4px;
}
.upload_game_img .show_img {
  width: 267px;
  height: 178px;
  border-radius: 4px;
  vertical-align: middle;
}
.item_list{
  float: left;
  margin: 10px 20px 10px 0;
}
.auth_text {
  color: #000000;
  line-height: 24px;
  height: 58px;
}
</style>
